<%@ page pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hwhp.entity.*"%>
<%@ page import="com.hwhp.service.console.DepartService,com.hwhp.service.console.impl.DepartServiceImpl" %>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	DepartService departService = new DepartServiceImpl();
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>权限分配处理sort_asc.gif</title>
		<LINK href="<%=basePath%>css/milkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>css/htmilkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>js/tree/dtree/dtree.css" type=text/css
			rel=StyleSheet>
		<script type="text/javascript">
			var basepath='<%=basePath%>';
	    </script>
		<script type="text/javascript"
			src="<%=basePath%>/js/tree/xtree/xloadtree/json.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>/js/tree/xtree/xloadtree/xtree.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>/js/tree/xtree/xloadtree/xmlextras.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>js/tree/xtree/xloadtree/xloadtree.js"></script>
	</head>
	<body style="MARGIN: 0px;" onunload="init()" id="body">
		<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%"
			align=center border=0>
			<TBODY>
				<TR>
					<TD style="WIDTH:100%; HEIGHT: 12px" background=<%=basePath%>
						images/commom/index_r4_c9.jpg colSpan=2></TD>
				</TR>
				<TR>
					<TD align=top width=100%>
						<TABLE height="100%" cellSpacing=0 cellPadding=0 width="90%"
							border=0 align="center">
							<TBODY>
								<TR>
									<TD height=26>
										<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0
											align="center">
											<TBODY>
												<TR>
													<TD class=linelabel3 vAlign=bottom background=<%=basePath%>images/commom/00_r5_c30.jpg>
														系统管理>>权限配置
													</TD>
												</TR>
											</TBODY>
										</TABLE>
									</TD>
								</TR>
								<TR>
									<TD class=border2 width="90%" height="100%">

										<FORM id=form name=form action=/oaweb/hetong/htstatform.form
											method=post>
											<TABLE id=tab1 height="100%" width="100%" cellSpacing=0 cellPadding=0 border=0>
												<TBODY>
													<TR>
														<TD class=middlemiddle width="200px">
														 <TABLE cellSpacing=10 width="100%" height="100%">
			                                                <TBODY>
			                                                  	<TR>
					                                               <TD class=contenttab1 vAlign=top>
			<script type="text/javascript">
				   var orgTree = new WebFXTree("组织机构");
				   var theArray = new Array();
				   var length=0;
				<%
				String action="";
				 //选择树初始化参数
				int itype=1;//type=0 无选择　type=1　复选框　type=2　单选框
				List<Deptment> list=(List<Deptment> )request.getAttribute("deptList");
						if(list!=null&&list.size()>0){
						  for(Deptment dept:list){
						    String src=basePath+"html/manager/accredit/departSelectSubTree.jsp";
						    //String src= basePath+"html/manager/deptment/departManagerSubTree.jsp";;
						    String deptid=dept.getDeptId();
						    String deptname=dept.getDeptName();
						    System.out.println("deptName:"+deptname);
						    List<Deptment> subList = departService.getChildDepts(deptid);
						    if(subList!=null&&subList.size()>0){
						      src=src+"?deptid="+deptid;
						      action="javascript:doSelect('"+deptid+"')";
						    }else{
						      src="";
						      action="javascript:doSelect('"+deptid+"')";
						    }
				%>
				var currentTree =  orgTree.add(new WebFXLoadTreeItem("<%=deptname%>","<%=src%>","<%=action%>",null,null,null,"<%=itype%>","<%=deptid%>"));
				theArray[length] = currentTree;
				 length++;
				<%
				   }
				   }
				%>
				document.write(orgTree);
				for(var m=0;m < length;m++){
				 theArray[m].expand();
				}
			</script>
			         </TD>
				</TR>
			</TBODY>
		</TABLE>
														</TD>
														<TD class=middlemiddle>
														  <iframe id="workspace0" name="workspaceframe0" frameborder="0" scrolling="no" src="/chis/manager/role!userDistributeList.action" width="100%" height="99%">
								                            </iframe>
														</TD>
													</TR>
												</TBODY>
											</TABLE>
										</FORM>
									</TD>
								</TR>
							</TBODY>
						</TABLE>
					</TD>
				</TR>
			</TBODY>
		</TABLE>
	</body>
	<script type="text/javascript">
	function init(){
	  var success=document.getElementById("success").value
	  if(success=='true'){
	    alert("权限配置成功！");
	  }
	  if(success=='false'){
	    alert("权限配置失败！");
	  }
	}
	  function doSelect(deptid){
	  	//alert(deptid);
	     workspace0.location="/chis/manager/role!userDistributeList.action?deptid="+deptid+"&Random="+Math.random();
	     
	  }
	</script>
</html>
